/**
 * ExportExcelInterceptor.java	  V1.0   Feb 15, 2012 8:19:31 PM
 *
 * Copyright 2011 AsiaInfo Linkage, All rights reserved.
 *
 * Modification history(By    Time    Reason):
 * 
 * Description:
 */

package xframe.core.interceptor;

import java.io.InputStream;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import xframe.core.utils.CoreConstants;
import xframe.core.utils.FlexiGridJsonToFile;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


/**
 * 功能描述：用于分离普通操作和Excel导出操作的拦截器
 *
 * @author  余根宁
 *
 * <p>修改历史：(修改人，修改时间，修改原因/内容)</p>
 */
public class ExportExcelInterceptor extends AbstractInterceptor {
    
    /* (non-Javadoc)
     * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
     */
    @Override
    public String intercept(ActionInvocation arg0) throws Exception {
        
        HttpServletRequest request = ServletActionContext.getRequest();
        String type = request.getParameter(CoreConstants.FlexiGridType);
        String colModel = request.getParameter(CoreConstants.FlexiGridColModel);
        //加入PreResultListener;
        arg0.addPreResultListener(new ExportExcelResultListener(type,colModel));
       
        //返回正常处理流程
        return arg0.invoke();
    }
    
}
